package com.rongji.dfish.hello.service;

import com.rongji.dfish.base.util.Utils;
import com.rongji.dfish.framework.service.impl.AbstractFrameworkService;
import com.rongji.dfish.hello.constant.DemoConstants;
import com.rongji.dfish.hello.dao.OrgDao;
import com.rongji.dfish.hello.entity.SysOrg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class OrgService extends AbstractFrameworkService<SysOrg, SysOrg, String> {

    @Autowired
    private OrgDao dao;

    @Override
    public OrgDao getDao() {
        return dao;
    }

    public void setDao(OrgDao dao) {
        this.dao = dao;
    }

    public List<SysOrg> listChildren(String parent) {
        if (Utils.isEmpty(parent)) {
            return Collections.emptyList();
        }

        return dao.listChildren(parent, DemoConstants.STATUS_ENABLE);
    }

    public int updateStatus(String orgId, String orgStatus) {
        return dao.updateStatus(orgId, orgStatus);
    }

}
